package test.edu.demo.Filter.basic;

import org.junit.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import test.edu.demo.Autowired.IUser;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author xiao.hu
 * @date 2021-08-28
 * @apiNote
 */
public class UserFilter implements Filter {

    @Autowired
    private IUser user;

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("UserFilter doFilter()");
        /**
         * 因为当前包下扫描不到IUser的实现类
         */
        Assert.assertTrue(user == null);
        chain.doFilter(request, response);
        //user.say();
    }

    @Override
    public void destroy() {
    }
}
